---
title: Snapshot/restore task state
summary: Capture and later restore a task's in-memory field values for edit/cancel support.
status: draft
owner: SAIF Documentation
last_reviewed: 2026-08-21
library: SAIF.Business.Tasks
reference_type: embedded
operation_id: OP-11
trigger: Framework edit/cancel lifecycle (StoreValues / RestoreValues)
---

# Snapshotrestore task state

This operation captures a task's current field values into an in-memory snapshot (`TaskStore`) and can later restore them, supporting the framework's edit/cancel lifecycle.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-11 |
| **Trigger** | Framework edit/cancel lifecycle |
| **Inputs** | `clsTask` instance |
| **Outputs** | `TaskStore` snapshot / restored field values |
| **Primary components** | `clsTask.StoreValues`, `clsTask.RestoreValues` |
| **Entry point** | `SAIF.Business.Tasks/clsTask.vb` |

## Steps

1. `StoreValues` builds a fresh `TaskStore` hashtable with 25 keyed values; smart types are stored only when non-empty.
2. `RestoreValues` reads the stored values back, rehydrating smart types as "original", and ends with `MarkOld()`.
   - Defect: `StoreValues` stores context text under key `ContextText`, but `RestoreValues` reads key `ContextTextValue` — the restored context text is therefore always empty.*

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
flowchart TD
	Start([Edit lifecycle begins]) --> S1["StoreValues builds TaskStore<br>with 25 keys"]
	S1 --> Edit[Caller edits task fields]
	Edit --> D{Cancel edit?}
	D -->|Yes| S2["RestoreValues reads<br>TaskStore back"]
	S2 --> S3[MarkOld]
	D -->|No| EndOk([Edit committed via Save])
	S3 --> EndRestored([Original values restored])
```

## Failure and edge-case behavior

- Context text is never correctly restored due to the `ContextText` / `ContextTextValue` key mismatch between `StoreValues` and `RestoreValues` — whether this is an intentional omission or a defect is unknown.**

## Related documentation
- [Operations and processes](../operations-processes.md)

> **Note:** Statements marked with * were inferred from code structure, naming conventions, or
> contextual evidence where direct confirmation was not available in source artifacts. Statements
> marked with ** could not be confirmed; treat as unknown until verified.

## Sources
- SAIF.Business.Tasks/clsTask.vb
